<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>权限管理系统</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">
    <!--表单验证bootstrapValidator CSS-->
    <link rel="stylesheet" type="text/css"
          href="/node_modules/bootstrapvalidator/dist/css/bootstrapValidator.min.css">
    <!--动态表格bootstrap-table CSS-->
    <link rel="stylesheet" href="/node_modules/bootstrap-table/dist/bootstrap-table.min.css">
    <!--树形ztree CSS-->
    <link rel="stylesheet" href="/node_modules/ztree/css/zTreeStyle/zTreeStyle.css">
    <!--树形ztree主题 CSS-->
    <link rel="stylesheet" href="/node_modules/ztree/css/metroStyle/metroStyle.css">
    <!--树形表格 CSS-->
    <link rel="stylesheet" href="/node_modules/jquery-treegrid/css/jquery.treegrid.css">
    <link rel="stylesheet" href="/static/css/animate.css">
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- jQuery -->
    <script src="/node_modules/jquery/jquery.min.js"></script>
    <!-- Bootstrap JavaScript -->
    <script src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
    <!--表单验证bootstrapValidator js-->
    <script type="text/javascript" src="/node_modules/bootstrapvalidator/dist/js/bootstrapValidator.min.js"></script>
    <!--动态表格bootstrap-table js-->
    <script type="text/javascript" src="/node_modules/bootstrap-table/dist/bootstrap-table.min.js"></script>
    <!--动态表格bootstrap-table 汉化 js-->
    <script type="text/javascript" src="/node_modules/bootstrap-table/dist/locale/bootstrap-table-zh-CN.min.js"></script>
    <!--树形ztree js-->
    <script type="text/javascript" src="/node_modules/ztree/js/jquery.ztree.all.min.js"></script>
    <!--树形表格 js-->
    <script type="text/javascript" src="/node_modules/jquery-treegrid/js/jquery.treegrid.min.js"></script>
    <!--属性表格bootstrap js支持-->
    <script type="text/javascript" src="/node_modules/jquery-treegrid/js/jquery.treegrid.bootstrap3.js"></script>
    <script type="text/javascript" src="/node_modules/jquery-treegrid/js/jquery.cookie.js"></script>
    <!--自定义属性表格 js（使其能够异步加载数据）-->
    <script type="text/javascript" src="/static/js/jquery.treegrid.extension.js?v=0.0060"></script>
    <script type="text/javascript" src="/static/js/layer-v3.1.1/layer/layer.js"></script>
    <script type="text/javascript" src="/static/js/laydate/laydate.js"></script>
    <!--表格数据导出-->
    <script type="text/javascript" src="/static/js/tableExport/libs/FileSaver/FileSaver.min.js"></script>
    <script type="text/javascript" src="/static/js/tableExport/libs/js-xlsx/xlsx.core.min.js"></script>
    <script type="text/javascript" src="/static/js/tableExport/libs/jsPDF/jspdf.min.js"></script>
    <script type="text/javascript" src="/static/js/tableExport/libs/jsPDF-AutoTable/jspdf.plugin.autotable.js"></script>
    <script type="text/javascript" src="/static/js/tableExport/libs/es6-promise/es6-promise.auto.min.js"></script>
    <script type="text/javascript" src="/static/js/tableExport/libs/html2canvas/html2canvas.min.js"></script>
    <script type="text/javascript" src="/static/js/tableExport/tableExport.js"></script>
    <script type="text/javascript" src="/node_modules/bootstrap-table/dist/extensions/export/bootstrap-table-export.js"></script>
    <!--表格数据打印-->
    <script type="text/javascript"
            src="/node_modules/bootstrap-table/dist/extensions/print/bootstrap-table-print.js?a=0"></script>
    <!--表格数据筛选-->
    <link rel="stylesheet" href="/node_modules/bootstrap-table/dist/extensions/filter-control/bootstrap-table-filter-control.css">
    <script type="text/javascript"
            src="/node_modules/bootstrap-table/dist/extensions/filter-control/bootstrap-table-filter-control.js"></script>
    <style>
        .left-menu .menu-table > thead {
            color: #3c763d;
            background-color: #dff0d8;
            border-color: #d6e9c6;
        }

        .left-menu .menu-table tr td, tr td a {
            color: #009688;
            padding: 3px 3px 0px;
        }

        .left-menu .menu-table tr td a:hover {
            color: #00F7DE;
            text-decoration: none;
        }

        .left-menu .menu-table tr td:hover {
            background-color: #dff0d8;
        }

        .left-menu .menu-table {
            margin-bottom: 0px;
        }

        .left-menu .fixed-table-container {
            border: none;
        }
        .modal-backdrop {
            position: inherit;
        }
    </style>
    <!--自定义全局函数-->
    <script type="text/javascript">
        let wpgaci = {
            goUrl: function (url, mins) {
                setTimeout(function () {
                    window.location.href = url;
                }, mins * 1000);
            }
        };
    </script>
</head>
<body>
<div class="container-fluid">
    <nav class="navbar navbar-default animated fadeInDown" role="navigation">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="{:url('/sys/index/index')}">权限管理系统</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse navbar-ex1-collapse">
                <ul class="nav navbar-nav">
                    <!--<li><a href="{:url('index/city/tree')}">treeTable</a></li>-->
                    <!--<li><a href="{:url('index/city/index')}">ztree</a></li>-->
                    <!--<li><a href="{:url('index/user/index')}">bootstrap-table</a></li>-->
                    <!--<li><a href="{:url('index/echart/index')}">echart</a></li>-->
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    {if session('loginUserId')}
                    <li><a href="{:url('/sys/login/my_info')}">{:session('loginUser')->nick}【{:session('loginUser')
                        ->role_name}】</a></li>
                    <li><a href="{:url('/sys/login/logout')}">退出</a></li>
                    {else}
                    <li><a href="{:url('/sys/login/login')}">登陆</a></li>
                    {/if}
                </ul>
            </div><!-- /.navbar-collapse -->
        </div>
    </nav>
    <div class="row">
        <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2 hidden-xs hidden-sm animated fadeInLeft">
            <div class="left-menu">
                <!-- 表格主体-->
                <table id="leftMenuTable" class="menu-table">
                </table>
                <!-- 表格数据处理（未完待续） -->
                <script type="text/javascript">
                    $(function () {
                        leftMenuView.init();
                    });
                    var leftMenuView = {
                        table: null,//表格对象
                        dataUrl: '/sys/menu/login_menu',//数据加载地址
                        delUrl: '',//删除数据地址
                        selectedData: null,//选中的数据,
                        id: 0,//操作数据的主键
                        defaultColumns: function () {
                            var that = this;
                            //表头数据列
                            return [
                                {
                                    field: 'name', title: '功能模块', formatter: function (argument, item) {
                                        if (item.parent_id == 0) {
                                            return argument;
                                        }
                                        var url = "/" + item.module_name + "/" + item.action_name + "/" +
                                            item.function_name + '.html';
                                        var html = "<label id='menu-" + item.module_name + '.' + item.action_name + "'>"
                                        html += "<a href='" + url + "'>" + argument + "</a>";
                                        html += "</label>";
                                        return html;
                                    }
                                }
                            ];
                        },
                        init: function () {
                            var that = this;
                            that.table = $('#leftMenuTable').bootstrapTreeTable({
                                id: 'id',// 选取记录返回的值
                                code: 'id',// 用于设置父子关系
                                parentCode: 'parent_id',// 用于设置父子关系
                                rootCodeValue: "",//设置根节点code值----可指定根节点，默认为null,"",0,"0"
                                type: 'get',//请求数据的ajax类型
                                url: that.dataUrl,   //请求数据的ajax的url
                                ajaxParams: {}, //请求数据的ajax的data属性
                                expandColumn: 0,//在哪一列上面显示展开按钮,从0开始
                                striped: true,   //是否各行渐变色
                                expandAll: true,  //是否全部展开
                                columns: this.defaultColumns(),//列数组
                                height: 650,//默认高度
                                responseHandler: function (argument) {
                                    //console.log(argument);
                                    if(!argument.status){
                                        layer.msg(argument.msg,{icon:2});
                                    }
                                    return argument;
                                },
                                expanderExpandedClass: 'glyphicon  glyphicon-triangle-bottom',
                                expanderCollapsedClass: 'glyphicon glyphicon-triangle-right',
                                //tree table渲染完成时执行
                                loadSuccess: that.loadSuccess,
                                saveState:true,//是否保存树的展开状态，必须把expandAll设置为true
                            });
                        },
                        loadSuccess:function () {
                            $('.left-menu .menu-table tr td').on('click', function () {
                                var url = $($($(this).children()[2]).children()[0]).attr('href');
                                console.log(url);
                                if (typeof url != "undefined") {
                                    wpgaci.goUrl(url);
                                }
                            });
                        }
                    }
                </script>
            </div>
        </div>
        <div class="col-xs-12 col-sm-12 col-md-10 col-lg-10 animated fadeInRight">
            {block name='body'}
                body
            {/block}
        </div>
    </div>
</div>
</body>
</html>